package action;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import dao.DeptDao;
import entity.Dept;
@ParentPackage("struts-default")
@Namespace("/dept")
@Controller
@Scope("prototype")
public class DeptAddAction {
    @Resource
	private DeptDao deptDao;
    private int no;
    private String name;
    private String password;
    
	public DeptDao getDeptDao() {
		return deptDao;
	}
	public void setDeptDao(DeptDao deptDao) {
		this.deptDao = deptDao;
	}
	public int getNo() {
		return no;
	}
	public void setNo(int no) {
		this.no = no;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@Action(value="add",results={
		@Result(name="success",type="dispatcher",location="/dept_delete.jsp")
	})
    public String excute(){
		Dept dept=new Dept();
		dept.setNo(no);
		dept.setName(name);
		dept.setpPssword(password);
    	deptDao.save(dept);
		return "success";
    	
    }
}
